﻿using LPP.Entity;
using LPP.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPP.Repository.UserReviewRepository
{
    public class UserReviewRepository
    {
        private readonly SqlDbContext _context;

        public UserReviewRepository(SqlDbContext context)
        {
            _context = context;
        }

        public async Task<List<UserReview>> GetUserReviewsAsync(int userId)
        {
            return await _context.UserReviews
                                 .Where(r => r.UserID == userId)
                                 .ToListAsync();
        }
        public async Task AddUserReviewAsync(UserReview review)
        {
            review.ReviewDate = DateTime.UtcNow; // 设置创建时间
            await _context.UserReviews.AddAsync(review);
            await _context.SaveChangesAsync();
        }
    }
}
